#ifndef __BACKPORT_LINUX_PHY_H
#define __BACKPORT_LINUX_PHY_H
#include_next <linux/phy.h>
#include <linux/version.h>


#if LINUX_VERSION_CODE < KERNEL_VERSION(5,4,0)
#define MDIO_MMD_NUM 32
#if 0
struct mdio_bus_stats {
	u64_stats_t transfers;
	u64_stats_t errors;
	u64_stats_t writes;
	u64_stats_t reads;
	/* Must be last, add new statistics above */
	struct u64_stats_sync syncp;
};
#endif
#define phy_read_poll_timeout(phydev, regnum, val, cond, sleep_us, \
				timeout_us, sleep_before_read) \
({ \
	int __ret = read_poll_timeout(phy_read, val, (cond) || val < 0, \
		sleep_us, timeout_us, sleep_before_read, phydev, regnum); \
	if (val <  0) \
		__ret = val; \
	if (__ret) \
		phydev_err(phydev, "%s failed: %d\n", __func__, __ret); \
	__ret; \
})

int phy_get_c45_ids(struct phy_device *phydev);

#endif
#endif /* __BACKPORT_LINUX_PHY_H */
